<?php
namespace Amis\form;
class Select extends FormItem
{
    public string $type = 'select';

    public function options($options)
    {
        $this->options = $options;
        return $this;
    }

    public function source($api)
    {
        $this->source = $api;
        return $this;
    }

    public function autoComplete(string $autoComplete)
    {
        $this->autoComplete = $autoComplete;
        return $this;
    }

    public function delimiter(string $delimiter = ',')
    {
        $this->delimiter = $delimiter;
        return $this;
    }

    public function labelField(string $labelField)
    {
        $this->labelField = $labelField;
        return $this;
    }

    public function valueField(string $valueField)
    {
        $this->valueField = $valueField;
        return $this;
    }

    public function joinValues(bool $joinValues = true)
    {
        $this->joinValues = $joinValues;
        return $this;
    }

    public function extractValue(bool $extractValue = false)
    {
        $this->extractValue = $extractValue;
        return $this;
    }

    public function checkAll(bool $checkAll = false)
    {
        $this->checkAll = $checkAll;
        return $this;
    }

    public function checkAllLabel(string $checkAllLabel = '全选')
    {
        $this->checkAllLabel = $checkAllLabel;
        return $this;
    }

    public function checkAllBySearch(bool $checkAllBySearch = false)
    {
        $this->checkAllBySearch = $checkAllBySearch;
        return $this;
    }

    public function defaultCheckAll(bool $defaultCheckAll = false)
    {
        $this->defaultCheckAll = $defaultCheckAll;
        return $this;
    }

    public function creatable(bool $creatable = false)
    {
        $this->creatable = $creatable;
        return $this;
    }

    public function multiple(bool $multiple = false)
    {
        $this->multiple = $multiple;
        return $this;
    }

    public function searchable(bool $searchable = false)
    {
        $this->searchable = $searchable;
        return $this;
    }

    public function createBtnLabel(string $createBtnLabel = '新增选项')
    {
        $this->createBtnLabel = $createBtnLabel;
        return $this;
    }

    /**
     * 自定义新增表单项
     * @param array $addControls
     * @return $this
     */
    public function addControls(array $addControls)
    {
        $this->addControls = $addControls;
        return $this;
    }

    public function addApi(string $addApi)
    {
        $this->addApi = $addApi;
        return $this;
    }

    public function editable(bool $editable = false)
    {
        $this->editable = $editable;
        return $this;
    }

    public function editControls(array $editControls)
    {
        $this->editControls = $editControls;
        return $this;
    }

    public function editApi(string $editApi)
    {
        $this->editApi = $editApi;
        return $this;
    }

    public function removable(bool $removable)
    {
        $this->removable = $removable;
        return $this;
    }

    public function deleteApi(bool $deleteApi)
    {
        $this->deleteApi = $deleteApi;
        return $this;
    }

    public function autoFill(array $autoFill)
    {
        $this->autoFill = $autoFill;
        return $this;
    }

    public function menuTpl(string $menuTpl)
    {
        $this->menuTpl = $menuTpl;
        return $this;
    }

    public function clearable(bool $clearable)
    {
        $this->clearable = $clearable;
        return $this;
    }

    public function hideSelected(bool $hideSelected)
    {
        $this->hideSelected = $hideSelected;
        return $this;
    }

    public function mobileClassName(string $mobileClassName)
    {
        $this->mobileClassName = $mobileClassName;
        return $this;
    }

    /**
     * 可选：group、table、tree、chained、associated。分别为：列表形式、表格形式、树形选择形式、级联选择形式，
     * 关联选择形式（与级联选择的区别在于，级联是无限极，而关联只有一级，关联左边可以是个 tree）。
     * @param string $selectMode
     * @return $this
     */
    public function selectMode(string $selectMode)
    {
        $this->selectMode = $selectMode;
        return $this;
    }

    /**
     * 如果不设置将采用 selectMode 的值，可以单独配置，参考 selectMode，决定搜索结果的展示形式。
     * @param string $searchResultMode
     * @return $this
     */
    public function searchResultMode(string $searchResultMode)
    {
        $this->searchResultMode = $searchResultMode;
        return $this;
    }

    /**
     * 当展示形式为 table 可以用来配置展示哪些列，跟 table 中的 columns 配置相似，只是只有展示功能。
     * @param array $columns
     * @return $this
     */
    public function columns(array $columns)
    {
        $this->columns = $columns;
        return $this;
    }

    /**
     * 当展示形式为 associated 时用来配置左边的选项集。
     * @param array $leftOptions
     * @return $this
     */
    public function leftOptions(array $leftOptions)
    {
        $this->leftOptions = $leftOptions;
        return $this;
    }

    /**
     * 当展示形式为 associated 时用来配置左边的选择形式，支持 list 或者 tree。默认为 list。
     * @param array $leftMode
     * @return $this
     */
    public function leftMode(string $leftMode)
    {
        $this->leftMode = $leftMode;
        return $this;
    }

    /**
     * 当展示形式为 associated 时用来配置右边的选择形式，可选：list、table、tree、chained。
     * @param string $rightMode
     * @return $this
     */
    public function rightMode(string $rightMode)
    {
        $this->rightMode = $rightMode;
        return $this;
    }
}